package com.ropeok.service.serviceimpl;

import com.ropeok.Exception.ServiceException;
import com.ropeok.constant.ResultConstant;
import com.ropeok.entity.permission;
import com.ropeok.mapper.PermissionMapper;
import com.ropeok.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public void SavePermission(permission permission) {
        List<Long> AllUserId = permissionMapper.FindPermissionId();
        if (AllUserId.contains(permission.getPermissionid())){
            throw new ServiceException(ResultConstant.ID_IS_EXIST,"用户已存在");
        }
        permissionMapper.Save(permission);
    }
}
